
#ifndef BITMAP_H
#define BITMAP_H

#include <string>
#include "grid.hpp"
#include "settings.hpp"

class bitmap	//for 24-bit bitmaps
{
public:
	bitmap();
	bitmap(const std::string & path);
	~bitmap();

	bool load(const std::string & path);
	bool operator! () const { return !alright; }
	uword operator()(unsigned int x, unsigned int y) const;
    grid::region region(const std::string & path = std::string(), const color & ignored = settings::ignored_color);
    grid::boundary boundary(const color & ignored = settings::ignored_color);

	const uword & width() const { return w; }
	const uword & height() const { return h; }

private:
	enum bmp_offset { OFFSET = 10, HEADER_SIZE=14, WIDTH=18, HEIGHT=22, NUM_COLOR_PLANES=26, BPP=28, COMPRESSION=30, IMG_SIZE=34 };
	bool alright;
	char* data;
	uword h, w, offset, bpp, pixelsz;   //note: pixelsz = bpp/BITS_PER_CHAR
	std::string file_path;
};

#endif //BITMAP_H

